//package com.shopoo.authorization.app.provider;
//
//import com.alibaba.fastjson.JSON;
//import jakarta.annotation.Resource;
//
//import org.springframework.security.authentication.AuthenticationProvider;
//import org.springframework.security.authentication.BadCredentialsException;
//import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
//import org.springframework.security.core.Authentication;
//import org.springframework.security.core.AuthenticationException;
//import org.springframework.security.core.userdetails.UserDetails;
//import org.springframework.security.core.userdetails.UserDetailsService;
//import org.springframework.stereotype.Component;
//
///**
// *
// * @Author <a href="mailto:android_li@sina.cn">MaoYuan.Li</a>
// * @Date 2023/1/14 21:14
// */
//@Component
//public class AdminSmsAuthenticationProvider implements AuthenticationProvider {
//
//	//由于我有两个用户表，所以针对不同的userDetailservice需要指定
//	@Resource
//	private UserDetailsService userDetailsService;
//
//	@Override
//	public Authentication authenticate(Authentication authentication) throws AuthenticationException {
//		UsernamePasswordAuthenticationToken adminLoginToken = (UsernamePasswordAuthenticationToken) authentication;
//		System.out.println("===进入AdminSMS登录验证环节====="+ JSON.toJSONString(adminLoginToken));
//		UserDetails userDetails = userDetailsService.loadUserByUsername(adminLoginToken.getName());
//		//匹配短信验证码。进行密码校验，最终需要返回一个验证过的Token
//		if("666666".equals(authentication.getCredentials().toString())){
//			return  new UsernamePasswordAuthenticationToken(userDetails, userDetails.getPassword(), userDetails.getAuthorities());
//		}
//		throw new BadCredentialsException("验证码不正确");
//	}
//
//	//判断是否支持当前Token，从而决定是否需要进行认证校验
//	//由于oauth2默认采用的userNamePasswordToken所以在最简方式中，可以依然采用
//	@Override
//	public boolean supports(Class<?> authentication) {
//		//为了简化代码，默认采用UsernamePasswordAuthenticationToken
//		return UsernamePasswordAuthenticationToken.class.isAssignableFrom(authentication);
//	}
//}
